package com.huawei.cloud.fc.controller;

import com.huawei.cloud.fc.pojo.User;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.net.URI;

/**
 * Created by cwx183898 on 2017/5/23.
 */
@RestController
public class FcController {
    @Autowired
    UserInterface ui;

    @RequestMapping(path = "/fc/get")
    @HystrixCommand(fallbackMethod = "getFallbackUser")
    public User get(String username, String password) {
        return ui.get(username, password);
    }


    public User getFallbackUser(String username, String password) {
        User user = new User();
        user.setUsername("熔断生效");
        return user;
    }
}
